[logic]
active = nil;sr_idle@wait_for_start

[sr_idle@wait_for_start]
on_info = {+zat_b5_actor_help_dealer -zat_b5_trader_death =actor_on_level(jupiter)} sr_idle@cleanup %+jup_b207_task_start%
on_info2 = {+zat_b5_trader_death} sr_idle@switch %+jup_b207_ui%
on_info3 = {=actor_has_item(device_pda_zat_b5_dealer)} sr_idle@switch %+jup_b207_ui%

[sr_idle@cleanup]
on_info = {=squad_exist(zat_b5_dolg_squad)} sr_idle@start %=remove_squad(zat_b5_dolg_squad)%, sr_idle@start

[sr_idle@start]
on_info = {+jup_b207_task_start} sr_idle@spawn_mercs %=create_squad(jup_b207_zat_b7_duty_illicit_dealer:jup_a6)%

[sr_idle@spawn_mercs]
on_info = {+jup_b207_morgan_blackmailed} sr_idle@wait_for_blackmail %=create_squad(jup_b207_merc_1:jup_b206) =create_squad(jup_b207_merc_2:jup_b32)%

[sr_idle@wait_for_blackmail]
on_info = {+jup_b207_morgan_gived_depot} sr_idle@depot_change %=give_task(zat_b207_morgan_depot_task) =create_squad(jup_b207_zat_b7_duty_illicit_dealer_depot:jup_b207)%
on_info2 = {+jup_b207_dealer_disappear} sr_idle@nil %=remove_squad(jup_b207_zat_b7_duty_illicit_dealer)%
 
[sr_idle@depot_change]
on_info = {=dist_to_story_obj_ge(zat_b7_duty_illicit_dealer:150)} sr_idle@move_squad %=remove_squad(jup_b207_zat_b7_duty_illicit_dealer)%

[sr_idle@move_squad]
on_game_timer = 25 | sr_idle@save %=create_squad_member(zat_b7_duty_illicit_dealer:jup_b207_zat_b7_duty_illicit_dealer_depot)%

[sr_idle@save]
on_info = {-jup_b207_arrived_to_duty_depot =actor_in_zone(jup_b207_sr_depot_attack)} %+jup_b207_arrived_to_duty_depot =scenario_autosave(st_save_jup_b207_arrived_to_duty_depot)%
on_info2 = {+jup_b207_arrived_to_duty_depot} sr_idle@wait_for_ambush

[sr_idle@wait_for_ambush]
on_info = {=squad_exist(jup_b207_zat_b7_duty_illicit_dealer_depot) =actor_in_zone(jup_b207_sr_control)} sr_idle@ambush_merc_add %=set_squad_enemy_to_actor(jup_b207_zat_b7_duty_illicit_dealer_depot) =create_squad(jup_b207_depot_mercs:jup_b207) +jup_b207_morgan_ambush%
on_info2 = {=squad_exist(jup_b207_zat_b7_duty_illicit_dealer_depot) +jup_b207_morgan_ambush} sr_idle@ambush_merc_add %=set_squad_enemy_to_actor(jup_b207_zat_b7_duty_illicit_dealer_depot) =create_squad(jup_b207_depot_mercs:jup_b207)%
on_game_timer = 300 | {!actor_in_zone(jup_b207_sr_depot_attack)} sr_idle@save %-jup_b207_arrived_to_duty_depot%

[sr_idle@ambush_merc_add]
on_info = sr_idle@nil %=create_squad_member(sim_default_killer_2:jup_b207_depot_mercs:jup_b207_depot_mercs_2_spawn)%
 
[sr_idle@switch]
on_info = {+jup_b207_freedom_knows_about_depot} sr_idle@cutscene %=create_squad(jup_b207_freedom_depot:jup_b207)%
on_info2 = {+jup_b207_duty_knows_about_depot} sr_idle@cutscene %=create_squad_member(sim_default_duty_1:jup_b207_duty_base:jup_a6_spawn_point) =create_squad_member(sim_default_duty_1:jup_b207_duty_base:jup_a6_spawn_point) =create_squad(jup_b207_freedom_depot:jup_b207)%

[sr_idle@cutscene]
on_info = {!talking} sr_idle@cutscene_done %-jup_b207_ui%

[sr_idle@cutscene_done]
on_info = {+jup_b207_ui -jup_b207_lock_door} sr_idle@after_cutscene %=give_task(zat_b207_depot_reward_task)%

[sr_idle@after_cutscene]
on_info = {-jup_b207_freedom_in_depot =squad_in_zone(jup_b207_freedom_base:jup_b207_sr_depot_attack)} %+jup_b207_freedom_in_depot%
on_info2 = {-jup_b207_attack_started =is_squad_enemy_to_actor(jup_b207_duty_base)} %+jup_b207_attack_started%
on_info3 = {-jup_b207_attack_started =is_squad_enemy_to_actor(jup_b207_freedom_depot)} %+jup_b207_attack_started%
on_info4 = {-jup_b207_attack_started =is_squad_enemy_to_actor(jup_b207_freedom_base)} %+jup_b207_attack_started%
on_info5 = {+jup_b207_attack_started !squad_exist(jup_b207_duty_base)} sr_idle@after_attack
on_info6 = {+jup_b207_attack_started +jup_b207_freedom_knows_about_depot !squad_exist(jup_b207_freedom_depot) !squad_exist(jup_b207_freedom_base)} sr_idle@after_attack
on_info7 = {+jup_b207_attack_started -jup_b207_freedom_knows_about_depot !squad_exist(jup_b207_freedom_depot)} sr_idle@after_attack

[sr_idle@after_attack]
on_info = {!squad_exist(jup_b207_duty_base)} sr_idle@check_for_goodwill %+jup_b207_attack_end +jup_b207_freedom_wins%
on_info2 = {+jup_b207_freedom_knows_about_depot !squad_exist(jup_b207_freedom_depot) !squad_exist(jup_b207_freedom_base)} sr_idle@check_for_goodwill %+jup_b207_attack_end +jup_b207_duty_wins%
on_info3 = {-jup_b207_freedom_knows_about_depot !squad_exist(jup_b207_freedom_depot)} sr_idle@check_for_goodwill %+jup_b207_attack_end +jup_b207_duty_wins%

[sr_idle@check_for_goodwill]
on_info = {+jup_b207_duty_wins +jup_b207_duty_knows_about_depot} sr_idle@nil %=inc_faction_goodwill_to_actor(dolg:500) =dec_faction_goodwill_to_actor(freedom:250)%
on_info2 = {+jup_b207_freedom_wins +jup_b207_freedom_knows_about_depot} sr_idle@nil %=inc_faction_goodwill_to_actor(freedom:500) =dec_faction_goodwill_to_actor(dolg:250)%
on_info3 = sr_idle@warn

[sr_idle@warn]
on_info = {+jup_b207_guards_warning_actor} sr_idle@warn_timer

[sr_idle@warn_timer]
on_game_timer = 200 | sr_idle@warn %-jup_b207_guards_warning_actor%

[sr_idle@nil]
